<template>
  <div>
    <div class="header">
      <img src="http://static.shonemore.com/yk/WechatIMG2800.png" />
      <span class="title">悦客VIP后台管理系统</span>
      <div class="userInfo">
        <span>{{ name }}</span>
        <el-button
          type="text"
          style="padding: 0; color: #6f737a; font-size: 18px"
          @click="loginOut"
          >退出</el-button
        >
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "headBar",
  data() {
    return {
      name: "",
    };
  },

  computed: {
    // name: function () {
    //   let name = localStorage.getItem('name');
    //   return name;
    // },
  },
  mounted() {
    this.name = localStorage.getItem("name");
    console.log(this.name);
  },

  methods: {
    //退出登录
    loginOut() {
      this.$confirm("确定退出吗", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
      })
        .then(() => {
          localStorage.clear();
          this.$router.push({ path: "/login" });
        })
        .catch(() => {});
    },
  },
};
</script>

<style scoped>
.header {
  width: 93.75%;
  height: 50px;
  background: #252629;
  padding: 0 3.125%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  
}
.title {
  position: absolute;
  left: 11%;
  color: #fff;
  font-size: 1.4rem;
}
.header > img {
  width: 120px;
  vertical-align: bottom;
}
.userInfo {
  display: flex;
  flex-direction: row;
  align-items: center;
}
.userInfo > span {
  margin-right: 40px;
  color: #fff;
  font-size: 18px;
  font-weight: bold;
}
</style>
